
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports _2bMatesSite.BO

Namespace _2bMatesSite
	''' <summary>
	''' Summary description for account_settings.
	''' </summary>
	Public Partial Class account_settings
		Inherits BaseWebPage
		Protected chkPrivacysett As System.Web.UI.WebControls.CheckBox

		Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
			' Auto login from an external link
			'AutoLogin( Request );

			'User usr=new User();
			'email.Text = usr.GetEmail();
			' this.pageTemplate.PageTitle = PageTitles.ACCOUNT_SETTIINGS_PAGE;

			' init page from XML
			Me.initPageTitles(Constants.ACCOUNT_SETTINGS_PAGE, "", Form1, Nothing, Nothing)
			Me.initAdvertisements(Form1, Nothing)

			Dim usr As User = LoggedUser
			If usr = Nothing Then
				Common.Utils.RedirectToLoginPage(Page)
			End If

			btnCancel.Attributes("onclick") = "javascript: history.back(); return false;"

			If Constants.SHOW_GROUPS <> Constants.SHOW_ON Then
				trGroupNotification.Visible = False
				trGroupPrivacySettings.Visible = False
			Else
				trGroupNotification.Visible = True
				trGroupPrivacySettings.Visible = True
			End If

			If Constants.SHOW_MUSIC <> Constants.SHOW_ON Then
				trSpecialSettings.Visible = False
			Else
				trSpecialSettings.Visible = True
			End If

			If Not Me.IsPostBack Then
				If usr.EnableEmailNotify Then
					rNotificationyes.Checked = True
				Else
					rNotificationno.Checked = True
				End If

				If usr.EnableGroupEmailNotify Then
					rGroupNotificationyes.Checked = True
				Else
					rGroupNotificationno.Checked = True
				End If

				If usr.EnableNewsletter Then
					rNewsletteryes.Checked = True
				Else
					rNewsletterno.Checked = True

					' commented on 24.09.2004
					'if( usr.Status == Constants.UNCONFIRMED_STATUS)
					'{
					'	rNotificationyes.Enabled = false;
					'	rNotificationno.Enabled = false;
					'}
				End If
			End If
		End Sub

		#region Web Form Designer generated code
		Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)
			'
			' CODEGEN: This call is required by the ASP.NET Web Form Designer.
			'
			InitializeComponent()
			MyBase.OnInit(e)
		End Sub

		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()

		End Sub
#End Region

		Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs)
			Dim usr As User = LoggedUser

			Dim notificationsEnabled As Integer = Convert.ToInt32(Request.Params(rNotificationyes.NamingContainer.UniqueID + ":" + rNotificationyes.GroupName))
			Dim groupNotificationsEnabled As Integer = Convert.ToInt32(Request.Params(rGroupNotificationyes.NamingContainer.UniqueID + ":" + rGroupNotificationyes.GroupName))

			If notificationsEnabled = Constants.NOTIFICATIONS_ENABLED Then
				usr.EnableEmailNotify = True
			Else
				usr.EnableEmailNotify = False
			End If

			If groupNotificationsEnabled = Constants.NOTIFICATIONS_ENABLED Then
				usr.EnableGroupEmailNotify = True
			Else
				usr.EnableGroupEmailNotify = False
			End If

			Dim newslettersEnabled As Integer = Convert.ToInt32(Request.Params(rNewsletteryes.NamingContainer.UniqueID + ":" + rNewsletteryes.GroupName))

			If newslettersEnabled = Constants.NEWSLETTER_ENABLED Then
				usr.EnableNewsletter = True
			Else
				usr.EnableNewsletter = False
			End If

			usr.Save()
			lblMessage.Visible = True
		End Sub

		====================
        ' This public property was added by conversion wizard to allow the access of a protected, autogenerated member variable Form1.
		====================
        Public ReadOnly Property Form1() As System.Web.UI.HtmlControls.HtmlForm
            Get
                Return Migrated_Form1
            End Get
        End Property
        'set { Migrated_Form1 = value; }
    End Class
End Namespace






